package com.example.mybluetooth;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

public class Adapter  extends ArrayAdapter<pojo> {
    private TextView name,address;
    private int resourceid;
    public Adapter(@NonNull Context context, int resource, @NonNull List<pojo> objects) {
        super(context, resource, objects);
        resourceid = resource;
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        pojo pojo = getItem(position);
        if (convertView == null){
            convertView = LayoutInflater.from(getContext()).inflate(resourceid,parent,false);
        }
        name = convertView.findViewById(R.id.name);
        address = convertView.findViewById(R.id.address);
        name.setText(pojo.getName());
        address.setText(pojo.getAddress());
        return convertView;
    }
}
